package com.hankol.winecellar.bean

import android.annotation.SuppressLint
import com.baselibrary.BuildConfig
import com.baselibrary.Constants
import com.baselibrary.base.BasicBean
import com.baselibrary.router.ActivityRouter.WINE_CELLAR.WINCE_CELLAR_DETAIL
import com.baselibrary.utils.CommonUtil
import com.baselibrary.utils.SpUtils
import kotlinx.android.parcel.Parcelize

fun foodBean2SelectSendFriend2Bean(bean: WineryDataInfoBean): SelectSendFriend4Bean {
    var bannerListBean = CommonUtil.jsonToList(bean.winerySlideshow, WineryCoverBean::class.java)
    val imgs = mutableListOf<String>()
    for (coverBean in bannerListBean) {
        imgs.add(if (coverBean.type == 0) coverBean.coverUrl else coverBean.videoUrl)
    }
    return SelectSendFriend4Bean().apply {
        bean.let {
            id = it.id
            showType = Constants.DYNAMIC_TYPE_IMG
            cover = it.wineryImg
            images = imgs
            title = it.wineryName
            content = it.wineryDesc
            icon = ""
            name = SpUtils.getInstance().loadUserBean.data.name
            isFans = SpUtils.getInstance().loadUserBean.data.isFans
//            route = "thd7pq://foodStalls/foodMenuDetail?menuId=${bean.id}"
        }
    }
}


fun showShare2Bean2SelectSendFriend2Bean(bean: WineryDataInfoBean): SelectSendFriend4Bean {
    val path = "$WINCE_CELLAR_DETAIL?dealerCode=${bean.dealerCode}&id=${bean.wineryId}"
    var bannerListBean = CommonUtil.jsonToList(bean.winerySlideshow, WineryCoverBean::class.java)
    val imgs = mutableListOf<String>()
    for (coverBean in bannerListBean) {
        imgs.add(if (coverBean.type == 0) coverBean.coverUrl else coverBean.videoUrl)
    }
    return SelectSendFriend4Bean().apply {
        bean.let {
            id = it.id
            //动态类型  1：图片 2：视频 3话题、4文章、 5直播、6 百科  7 讲坛的视频详情
            showType = Constants.DYNAMIC_TYPE_IMG
            cover = it.wineryImg
            images = imgs
            title = it.wineryName
            content = it.wineryDesc
            icon = ""
            name = SpUtils.getInstance().loadUserBean.data.name
            isFans = SpUtils.getInstance().loadUserBean.data.isFans
            route = "${if (BuildConfig.DEBUG) "thd7pq:/" else "r3fuww:/"}${path}"
        }
    }
}


//转换成 选择好友所需要的bean
@SuppressLint("ParcelCreator")
@Parcelize
data class SelectSendFriend4Bean(var id: Long = 0,
                                 var showType: Int = 0,
                                 var cover: String = "",
                                 var images: List<String>? = emptyList(),
                                 var title: String = "",
                                 var content: String = "",
                                 var icon: String = "",
                                 var name: String = "",
                                 var isFans: Int = 0,
                                 var route: String = "",
                                 var liveState: Int = LIVE_STATE_NO_START) : BasicBean()
//直播状态  1 ：未开始  2：直播中 3：已结束
const val LIVE_STATE_NO_START=1
const val LIVE_STATE_ING=2
const val LIVE_STATE_END=3